<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Aggregate Return (GNU Compiler Collection (GCC) Internals)</title>

<meta name="description" content="Aggregate Return (GNU Compiler Collection (GCC) Internals)">
<meta name="keywords" content="Aggregate Return (GNU Compiler Collection (GCC) Internals)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Option-Index.html" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Stack-and-Calling.html" rel="up" title="Stack and Calling">
<link href="Caller-Saves.html" rel="next" title="Caller Saves">
<link href="Scalar-Return.html" rel="prev" title="Scalar Return">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
-->
</style>


</head>

<body lang="en">
<div class="subsection-level-extent" id="Aggregate-Return">
<div class="nav-panel">
<p>
Next: <a href="Caller-Saves.html" accesskey="n" rel="next">Caller-Saves Register Allocation</a>, Previous: <a href="Scalar-Return.html" accesskey="p" rel="prev">How Scalar Function Values Are Returned</a>, Up: <a href="Stack-and-Calling.html" accesskey="u" rel="up">Stack Layout and Calling Conventions</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h4 class="subsection" id="How-Large-Values-Are-Returned"><span>18.9.9 How Large Values Are Returned<a class="copiable-link" href="#How-Large-Values-Are-Returned"> &para;</a></span></h4>
<a class="index-entry-id" id="index-aggregates-as-return-values"></a>
<a class="index-entry-id" id="index-large-return-values"></a>
<a class="index-entry-id" id="index-returning-aggregate-values"></a>
<a class="index-entry-id" id="index-structure-value-address"></a>

<p>When a function value&rsquo;s mode is <code class="code">BLKmode</code> (and in some other
cases), the value is not returned according to
<code class="code">TARGET_FUNCTION_VALUE</code> (see <a class="pxref" href="Scalar-Return.html">How Scalar Function Values Are Returned</a>).  Instead, the
caller passes the address of a block of memory in which the value
should be stored.  This address is called the <em class="dfn">structure value
address</em>.
</p>
<p>This section describes how to control returning structure values in
memory.
</p>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-TARGET_005fRETURN_005fIN_005fMEMORY"><span class="category-def">Target Hook: </span><span><code class="def-type">bool</code> <strong class="def-name">TARGET_RETURN_IN_MEMORY</strong> <code class="def-code-arguments">(const_tree <var class="var">type</var>, const_tree <var class="var">fntype</var>)</code><a class="copiable-link" href="#index-TARGET_005fRETURN_005fIN_005fMEMORY"> &para;</a></span></dt>
<dd><p>This target hook should return a nonzero value to say to return the
function value in memory, just as large structures are always returned.
Here <var class="var">type</var> will be the data type of the value, and <var class="var">fntype</var>
will be the type of the function doing the returning, or <code class="code">NULL</code> for
libcalls.
</p>
<p>Note that values of mode <code class="code">BLKmode</code> must be explicitly handled
by this function.  Also, the option <samp class="option">-fpcc-struct-return</samp>
takes effect regardless of this macro.  On most systems, it is
possible to leave the hook undefined; this causes a default
definition to be used, whose value is the constant 1 for <code class="code">BLKmode</code>
values, and 0 otherwise.
</p>
<p>Do not use this hook to indicate that structures and unions should always
be returned in memory.  You should instead use <code class="code">DEFAULT_PCC_STRUCT_RETURN</code>
to indicate this.
</p></dd></dl>

<dl class="first-deffn first-defmac-alias-first-deffn">
<dt class="deffn defmac-alias-deffn" id="index-DEFAULT_005fPCC_005fSTRUCT_005fRETURN"><span class="category-def">Macro: </span><span><strong class="def-name">DEFAULT_PCC_STRUCT_RETURN</strong><a class="copiable-link" href="#index-DEFAULT_005fPCC_005fSTRUCT_005fRETURN"> &para;</a></span></dt>
<dd><p>Define this macro to be 1 if all structure and union return values must be
in memory.  Since this results in slower code, this should be defined
only if needed for compatibility with other compilers or with an ABI.
If you define this macro to be 0, then the conventions used for structure
and union return values are decided by the <code class="code">TARGET_RETURN_IN_MEMORY</code>
target hook.
</p>
<p>If not defined, this defaults to the value 1.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-TARGET_005fSTRUCT_005fVALUE_005fRTX"><span class="category-def">Target Hook: </span><span><code class="def-type">rtx</code> <strong class="def-name">TARGET_STRUCT_VALUE_RTX</strong> <code class="def-code-arguments">(tree <var class="var">fndecl</var>, int <var class="var">incoming</var>)</code><a class="copiable-link" href="#index-TARGET_005fSTRUCT_005fVALUE_005fRTX"> &para;</a></span></dt>
<dd><p>This target hook should return the location of the structure value
address (normally a <code class="code">mem</code> or <code class="code">reg</code>), or 0 if the address is
passed as an &ldquo;invisible&rdquo; first argument.  Note that <var class="var">fndecl</var> may
be <code class="code">NULL</code>, for libcalls.  You do not need to define this target
hook if the address is always passed as an &ldquo;invisible&rdquo; first
argument.
</p>
<p>On some architectures the place where the structure value address
is found by the called function is not the same place that the
caller put it.  This can be due to register windows, or it could
be because the function prologue moves it to a different place.
<var class="var">incoming</var> is <code class="code">1</code> or <code class="code">2</code> when the location is needed in
the context of the called function, and <code class="code">0</code> in the context of
the caller.
</p>
<p>If <var class="var">incoming</var> is nonzero and the address is to be found on the
stack, return a <code class="code">mem</code> which refers to the frame pointer. If
<var class="var">incoming</var> is <code class="code">2</code>, the result is being used to fetch the
structure value address at the beginning of a function.  If you need
to emit adjusting code, you should do it at this point.
</p></dd></dl>

<dl class="first-deffn first-defmac-alias-first-deffn">
<dt class="deffn defmac-alias-deffn" id="index-PCC_005fSTATIC_005fSTRUCT_005fRETURN"><span class="category-def">Macro: </span><span><strong class="def-name">PCC_STATIC_STRUCT_RETURN</strong><a class="copiable-link" href="#index-PCC_005fSTATIC_005fSTRUCT_005fRETURN"> &para;</a></span></dt>
<dd><p>Define this macro if the usual system convention on the target machine
for returning structures and unions is for the called function to return
the address of a static variable containing the value.
</p>
<p>Do not define this if the usual system convention is for the caller to
pass an address to the subroutine.
</p>
<p>This macro has effect in <samp class="option">-fpcc-struct-return</samp> mode, but it does
nothing when you use <samp class="option">-freg-struct-return</samp> mode.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-TARGET_005fGET_005fRAW_005fRESULT_005fMODE"><span class="category-def">Target Hook: </span><span><code class="def-type">fixed_size_mode</code> <strong class="def-name">TARGET_GET_RAW_RESULT_MODE</strong> <code class="def-code-arguments">(int <var class="var">regno</var>)</code><a class="copiable-link" href="#index-TARGET_005fGET_005fRAW_005fRESULT_005fMODE"> &para;</a></span></dt>
<dd><p>This target hook returns the mode to be used when accessing raw return
registers in <code class="code">__builtin_return</code>.  Define this macro if the value
in <var class="var">reg_raw_mode</var> is not correct.  Use <code class="code">VOIDmode</code> if a register
should be ignored for <code class="code">__builtin_return</code> purposes.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-TARGET_005fGET_005fRAW_005fARG_005fMODE"><span class="category-def">Target Hook: </span><span><code class="def-type">fixed_size_mode</code> <strong class="def-name">TARGET_GET_RAW_ARG_MODE</strong> <code class="def-code-arguments">(int <var class="var">regno</var>)</code><a class="copiable-link" href="#index-TARGET_005fGET_005fRAW_005fARG_005fMODE"> &para;</a></span></dt>
<dd><p>This target hook returns the mode to be used when accessing raw argument
registers in <code class="code">__builtin_apply_args</code>.  Define this macro if the value
in <var class="var">reg_raw_mode</var> is not correct.  Use <code class="code">VOIDmode</code> if a register
should be ignored for <code class="code">__builtin_apply_args</code> purposes.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-TARGET_005fEMPTY_005fRECORD_005fP"><span class="category-def">Target Hook: </span><span><code class="def-type">bool</code> <strong class="def-name">TARGET_EMPTY_RECORD_P</strong> <code class="def-code-arguments">(const_tree <var class="var">type</var>)</code><a class="copiable-link" href="#index-TARGET_005fEMPTY_005fRECORD_005fP"> &para;</a></span></dt>
<dd><p>This target hook returns true if the type is an empty record.  The default
is to return <code class="code">false</code>.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-TARGET_005fWARN_005fPARAMETER_005fPASSING_005fABI"><span class="category-def">Target Hook: </span><span><code class="def-type">void</code> <strong class="def-name">TARGET_WARN_PARAMETER_PASSING_ABI</strong> <code class="def-code-arguments">(cumulative_args_t <var class="var">ca</var>, tree <var class="var">type</var>)</code><a class="copiable-link" href="#index-TARGET_005fWARN_005fPARAMETER_005fPASSING_005fABI"> &para;</a></span></dt>
<dd><p>This target hook warns about the change in empty class parameter passing
ABI.
</p></dd></dl>

</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Caller-Saves.html">Caller-Saves Register Allocation</a>, Previous: <a href="Scalar-Return.html">How Scalar Function Values Are Returned</a>, Up: <a href="Stack-and-Calling.html">Stack Layout and Calling Conventions</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
